﻿<!--
// Author:   Murray Foxcroft - April 2009
// Comments: Button Control Template for buttons that would typically be placed on the window to do various actions. 
             These buttons are greyed out and are non-intrusive, but "pop" in to view when hovered over.
-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ControlTemplate x:Key="StealthButtonTemplate" TargetType="{x:Type Button}">    
        <ControlTemplate.Resources>
            <Storyboard x:Key="MouseOverButtonEffect">
                <ThicknessAnimation Storyboard.TargetName="ButtonBorder" Storyboard.TargetProperty="(Control.Margin)"
                 Duration="0:0:0.05" FillBehavior="Stop" From="0,0,0,0" To="2,2,2,2" AutoReverse="True" />
            </Storyboard>
        </ControlTemplate.Resources>
        <Grid x:Name="StealthButtonOuterGrid">
           <Border x:Name="ButtonBorder" CornerRadius="4,4,4,4" Margin="0,0,0,0" Background="Transparent" Opacity="0" BorderThickness="2"></Border>
            <Border x:Name="ButtonBorderFill" CornerRadius="4,4,4,4" Margin="0,0,0,0" Opacity="0.05" BorderThickness="3">
                <Border.Background>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Offset="0" Color="#006701"/>
                        <GradientStop Offset="1" Color="#00ef01"/>
                    </LinearGradientBrush>
                </Border.Background>
            </Border>
            <Border x:Name="ButtonContent" Margin="5,5,5,5">
                <Label x:Name="ContentPresenterLabel" Foreground="Black" Opacity="0.3" FontWeight="Bold" Width="Auto" HorizontalAlignment="Center">       
                    <ContentPresenter Height="Auto" Width="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" FlowDirection="LeftToRight" OverridesDefaultStyle="True"></ContentPresenter>
                </Label>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Trigger.Setters>
                    <Setter Property="Foreground" TargetName="ContentPresenterLabel" Value="White"></Setter>
                    <Setter Property="FontWeight" TargetName="ContentPresenterLabel" Value="Normal"></Setter>
                    <Setter Property="Opacity" TargetName="ContentPresenterLabel" Value="1"></Setter>
                    <Setter Property="Opacity" TargetName="ButtonBorderFill" Value="1"></Setter>
                    <Setter Property="Opacity" TargetName="ButtonBorder" Value="1"></Setter>
                    <Setter Property="BorderBrush" TargetName="ButtonBorder" Value="Black"></Setter>
                    <Setter Property="Button.BitmapEffect" TargetName="ButtonBorder">
                        <Setter.Value>
                            <OuterGlowBitmapEffect GlowColor="Gray" GlowSize="2" Opacity="0.75"></OuterGlowBitmapEffect>
                        </Setter.Value>
                    </Setter>
                </Trigger.Setters>
            </Trigger>
            <EventTrigger RoutedEvent="Grid.MouseEnter" SourceName="StealthButtonOuterGrid">
                <BeginStoryboard Storyboard="{StaticResource MouseOverButtonEffect}"/>
            </EventTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate> 
    <Style x:Key="StealthButton" TargetType="{x:Type Button}">
        <Setter Property="Template" Value="{StaticResource StealthButtonTemplate}" />
    </Style>
</ResourceDictionary>